{template head}

<body>
<script type="text/javascript">
var ajaxparam = {
		'url' : '{CONTROL_URL}?a={$action}'
};

function submitcheck()
{
	return true;
}

function saveinfo()
{
	if(!submitcheck())
	{
		return;
	}
	var url = '{SITE_URL}ajax/index.php?m=sendSMS';
	
	var data = {};

	var value =  $('#phone').val();
    var phone = value.split("\n");
	var content = $('#content').val();
	var datas = [];
   	for (x in phone)
	{
		if(phone[x].length>0)
		{
			datas.push(phone[x]);
		}
	}
	data.phone = datas;
	data.content = content;
	
	layer.load(2);
	var callback = function(data)
	{
		if(data.sign == -2)
		{
			window.location = data.url;
		}
		else
		{
			layer.closeAll('loading');
			if(data.sign == 1)
			{
				//添加成功,返回列表页
				layer.alert(data.msg,function(){
					window.location = $('#gotoList').attr('href');
				});
			}
			else
			{
				if(data.msg)
				{
					layer.msg(data.msg);
				}
				else
				{
					layer.msg('操作失败');
				}
			}
		}
	};
	makeAjax('post',url,data,callback);
}


function phoneStatic(obj)
{
    var value = obj.value;  
    var phone = value.split("\n");
   	var datas = [];
   	for (x in phone)
	{
		if(phone[x].length>0)
		{
			datas.push(phone[x]);
		}
	}
	
	 $('#youxiao').text(datas.length);
}

function wordStatic(obj)
{
    var value = obj.value;  
       // value = value.replace(/\n|\r/gi,"");  
    var len = value.length;
    $('#zifu').text(len);
    
    var tiao = Math.ceil(len/70);
    
    $('#tiao').text(tiao);
}  
</script>
<div class="wrapper">
	<div class="crumbs"><a href="javascript:;">短信管理</a> &gt;<a id="gotoList" href="{SITE_URL}index.php?a=smsM">短信列表</a> &gt; <span>{$pagetitle}</span> </div>
	<div class="container_tit clearfix mb20 ft14">
		
	<form id="savedata">
		<h2 class="form_tit">短信信息<span style="color:#FF0000">({$msginfo})</span></h2>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">手机号：</label>
				<textarea  onkeyup="phoneStatic(this);" id="phone" placeholder="可填写多个手机号，用换行分开" class="text w340" style="height:200px" name="phone"></textarea>
			</p>
			<p class="clearfix">
				<label class="name"></label>
				<span>当前手机号共<span id="youxiao">0</span>个</span>
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">短信内容：</label>
				<textarea  onkeyup="wordStatic(this);" id="content" placeholder="请输入短信内容" class="text w340" style="height:200px" name="content"></textarea>
			</p>
			<p class="clearfix">
				<label class="name"></label>
				<span>共 <span id="zifu">0</span>个字符, <strong id="tiao" style="color:#FF0000">1</strong>条短信</span>
			</p>
		</div>
        <div class="form_item clearfix">
			<p class="clearfix">
				<label class="name"></label>
			    <input type="button" class="btnblue" value="提交" onclick="saveinfo()" />
			</p>
		</div>
    </form>
    </div>
</div>
</body>
{template foot}
